$(function () {
    $('#recharge-btn').click(function (event) {
        event.preventDefault();
        var user_id = $("input[name='user_id']").val();
        var goods_id = document.getElementsByName("goods_id")[0].value;
        var number = $("input[name='number']").val();
        zlalert.alertConfirm({
            'msg':'您确定要执行购买操作吗？',
            'confirmCallback':function () {
                zlajax.post({
                    'url':'/cms/user_recharge/',
                    'data':{
                        'user_id':user_id,
                        'number':number,
                        'goods_id':goods_id,
                    },
                    'success':function (data) {
                        if(data['code']==200){
                            zlalert.alertToast(data['message']);
                            window.location.reload()
                        }else{
                            // console.log(data['message']);
                            const timer =setInterval(() => {
                                  zlalert.alertError(data['message']);
                                  clearInterval(timer);

                                }, 100);

                        }
                    }
                })
            }
        })
    })
});


$(function () {
    $('#create-deal-btn').click(function (event) {
        event.preventDefault();
        var user_id = $("input[name='user_id']").val();
        var other_id = $("input[name='other_id']").val();
        var price = $("input[name='price']").val();
        var goods_code = document.getElementsByName("type_id")[0].value;
        var num = $("input[name='num']").val();
        zlalert.alertConfirm({
            'msg':'您确定要执行转让操作吗？',
            'confirmCallback':function () {
                zlajax.post({
                    'url':'/cms/create_deal/',
                    'data':{
                        'user_id':user_id,
                        'other_id':other_id,
                        'price':price,
                        'goods_code':goods_code,
                        'num':num
                    },
                    'success':function (data) {
                        if(data['code']==200){
                            zlalert.alertToast(data['message']);
                            window.location.reload()
                        }else{
                            // console.log(data['message']);
                            const timer =setInterval(() => {
                                  zlalert.alertError(data['message']);
                                  clearInterval(timer);

                                }, 100);

                        }
                    }
                })
            }
        })
    })
});




